package com.admin.controller.v1;

import com.usian.apis.admin.AdChannelControllerApi;
import com.usian.model.admin.dtos.ChannelDto;
import com.usian.model.admin.pojos.AdChannel;
import com.usian.model.common.dtos.PageResponseResult;
import com.usian.model.common.dtos.ResponseResult;
import com.admin.service.AdChannelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/channel")
public class AdChannelController implements AdChannelControllerApi{

    @Autowired
    private AdChannelService adservice;


    @PostMapping("findAll")
    public PageResponseResult findAll(@RequestBody ChannelDto channelDto){
         return adservice.findAll(channelDto);
    }

    @GetMapping("findById/{id}")
    public ResponseResult findById(@PathVariable("id") Integer id){
        return adservice.findById(id);
    }

    @PostMapping("add")
    public ResponseResult add(@RequestBody AdChannel adChannel){
        return adservice.add(adChannel);
    }

    @PutMapping("edit")
    public ResponseResult edit(@RequestBody AdChannel adChannel){
        return adservice.edit(adChannel);
    }

    @DeleteMapping("del/{id}")
    public ResponseResult del(@PathVariable("id")Integer id){
        return adservice.del(id);
    }

    @PostMapping("find")
    @Override
    public ResponseResult find() {
        return adservice.find();
    }
}
